<!DOCTYPE html>
<html lang="en">
  <head>
    <title>拨打号码</title>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <style>
    html, body, a {
      margin: 0;
      padding: 0;
      font-size: 13px;
    }
    html, body {
      width: 100%;
      height: 100%;
      background-color: #faf2ec;
    }
    body {
      position: relative;
    }
    a {
      background-color: #eb8b44;
      color: #fff;
      font-size: 14px;
      font-weight: 500;
      text-decoration: none;
      border-radius: 6px;
      padding: 20px 40px;
      display: inline-block;
    }
    .call {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
    }
    .phone {
      background-color: #fff;
      margin-bottom: 20px;
      padding: 10px 20px;
      min-width: 120px;
      position: relative;
      line-height: 30px;
      display: none;
    }
    .phone.show {
      display: block;
    }
    .phone label {
      font-size: 14px;
      right: 20px;
      text-align: left;
      text-indent: 2em;
    }
    .phone label span {
      color: #eb8b44;
      font-size: 16px;
      font-weight: 600;
      padding: 0 6px;
    }
    .phone img {
      width: 30px;
      height: 30px;
    }
    </style>
  </head>
  <body>
    <div class="call">
      <div id="phoneId" class="phone">
        <img src="./assets/phone.png" alt="15187169993" />
        <label>若未能拨通我号码，已经复制到剪切板，可手动粘贴号码<span>15187169993</span>拨打。给你带来不便烦请谅解，十分抱歉</label>
      </div>

      <a onClick="handleLink()" href="tel:15187169993">点击联系我</a>
    </div>
    <script>
    function handleLink() {
      copyToClip('15187169993')
      document.getElementById("phoneId").setAttribute("class", "phone show");
    }
    function copyToClip(content) {
      const aux = document.createElement("input");
      aux.setAttribute("value", content);
      document.body.appendChild(aux);
      aux.select();
      document.execCommand("copy");
      document.body.removeChild(aux);
    }
    </script>
  </body>
</html>